home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / oji / nsJVMManager.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  8KB  |  262 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *
  24.  * Alternatively, the contents of this file may be used under the terms of
  25.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  26.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27.  * in which case the provisions of the GPL or the LGPL are applicable instead
  28.  * of those above. If you wish to allow use of your version of this file only
  29.  * under the terms of either the GPL or the LGPL, and not to allow others to
  30.  * use your version of this file under the terms of the MPL, indicate your
  31.  * decision by deleting the provisions above and replace them with the notice
  32.  * and other provisions required by the GPL or the LGPL. If you do not delete
  33.  * the provisions above, a recipient may use your version of this file under
  34.  * the terms of any one of the MPL, the GPL or the LGPL.
  35.  *
  36.  * ***** END LICENSE BLOCK ***** */
  37.  
  38. #ifndef nsJVMManager_h___
  39. #define nsJVMManager_h___
  40.  
  41. #include "jvmmgr.h"
  42. #include "prtypes.h"
  43. #include "nscore.h"
  44. #include "jni.h"
  45. #include "jsdbgapi.h"
  46. #include "nsError.h"
  47.  
  48. #include "nsjvm.h"
  49. #include "nsAgg.h"
  50. #include "jsjava.h"
  51. #include "nsVoidArray.h"
  52. #include "nsILiveConnectManager.h"
  53.  
  54. #include "nsIObserver.h"
  55.  
  56. class nsSymantecDebugManager;
  57. class nsIWebBrowserChrome;
  58.  
  59. /*******************************************************************************
  60.  * NsJVMManager is the interface to the JVM manager that the browser sees. All
  61.  * files that want to include java services should include this header file.
  62.  * nsIJVMManager is the more limited interface what the JVM plugin sees.
  63.  ******************************************************************************/
  64.  
  65. struct nsJVMManager : public nsIJVMManager, public nsIThreadManager, public nsILiveConnectManager, public nsIObserver {
  66. public:
  67.  
  68.     NS_DECL_AGGREGATED
  69.  
  70.     NS_DECL_NSIJVMMANAGER    
  71.  
  72.     NS_DECL_NSIOBSERVER
  73.  
  74.     /* from nsIThreadManager: */
  75.     
  76.     /**
  77.      * Returns a unique identifier for the "current" system thread.
  78.      */
  79.     NS_IMETHOD
  80.     GetCurrentThread(PRThread* *threadID);
  81.  
  82.     /**
  83.      * Pauses the current thread for the specified number of milliseconds.
  84.      * If milli is zero, then merely yields the CPU if another thread of
  85.      * greater or equal priority.
  86.      */
  87.     NS_IMETHOD
  88.     Sleep(PRUint32 milli = 0);
  89.  
  90.     /**
  91.      * Creates a unique monitor for the specified address, and makes the
  92.      * current system thread the owner of the monitor.
  93.      */
  94.     NS_IMETHOD
  95.     EnterMonitor(void* address);
  96.     
  97.     /**
  98.      * Exits the monitor associated with the address.
  99.      */
  100.     NS_IMETHOD
  101.     ExitMonitor(void* address);
  102.     
  103.     /**
  104.      * Waits on the monitor associated with the address (must be entered already).
  105.      * If milli is 0, wait indefinitely.
  106.      */
  107.     NS_IMETHOD
  108.     Wait(void* address, PRUint32 milli = 0);
  109.  
  110.     /**
  111.      * Notifies a single thread waiting on the monitor associated with the address (must be entered already).
  112.      */
  113.     NS_IMETHOD
  114.     Notify(void* address);
  115.  
  116.     /**
  117.      * Notifies all threads waiting on the monitor associated with the address (must be entered already).
  118.      */
  119.     NS_IMETHOD
  120.     NotifyAll(void* address);
  121.     
  122.     /**
  123.      * Creates a new thread, calling the specified runnable's Run method (a la Java).
  124.      */
  125.     NS_IMETHOD
  126.     CreateThread(PRThread **thread, nsIRunnable* runnable);
  127.     
  128.     /**
  129.      * Posts an event to specified thread, calling the runnable from that thread.
  130.      * @param threadID thread to call runnable from
  131.      * @param runnable object to invoke from thread
  132.      * @param async if true, won't block current thread waiting for result
  133.      */
  134.     NS_IMETHOD
  135.     PostEvent(PRThread *thread, nsIRunnable* runnable, PRBool async);
  136.  
  137.     /* from nsILiveConnectManager: */
  138.  
  139.     /**
  140.      * Attempts to start LiveConnect using the specified JSRuntime.
  141.      */
  142.     NS_IMETHOD
  143.     StartupLiveConnect(JSRuntime* runtime, PRBool& outStarted)
  144.     {
  145.         outStarted = MaybeStartupLiveConnect();
  146.         return NS_OK;
  147.     }
  148.     
  149.     /**
  150.      * Attempts to stop LiveConnect using the specified JSRuntime.
  151.      */
  152.     NS_IMETHOD
  153.     ShutdownLiveConnect(JSRuntime* runtime, PRBool& outShutdown)
  154.     {
  155.         outShutdown = MaybeShutdownLiveConnect();
  156.         return NS_OK;
  157.     }
  158.  
  159.     /**
  160.      * Indicates whether LiveConnect can be used.
  161.      */
  162.     NS_IMETHOD
  163.     IsLiveConnectEnabled(PRBool& outEnabled)
  164.     {
  165.         outEnabled = IsLiveConnectEnabled();
  166.         return NS_OK;
  167.     }
  168.  
  169.     /**
  170.      * Initializes a JSContext with the proper LiveConnect support classes.
  171.      */
  172.     NS_IMETHOD
  173.     InitLiveConnectClasses(JSContext* context, JSObject* globalObject);
  174.  
  175.     /**
  176.      * Creates a JavaScript wrapper for a Java object.
  177.      */
  178.     NS_IMETHOD
  179.     WrapJavaObject(JSContext* context, jobject javaObject, JSObject* *outJSObject);
  180.  
  181.     /* JVMMgr specific methods: */
  182.  
  183.     /* ====> From here on are things only called by the browser, not the plugin... */
  184.     NS_IMETHOD
  185.     GetClasspathAdditions(const char* *result);
  186.  
  187.     static NS_METHOD
  188.     Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
  189.  
  190.     nsIJVMPlugin* GetJVMPlugin(void) { return fJVM; }
  191.  
  192.     /* Unlike the nsIJVMPlugin::StartupJVM, this version handles putting
  193.      * up any error dialog: */
  194.     nsJVMStatus StartupJVM(void);
  195.     nsJVMStatus ShutdownJVM(PRBool fullShutdown = PR_FALSE);
  196.     nsJVMStatus GetJVMStatus(void);
  197.     void SetJVMEnabled(PRBool enabled);
  198.  
  199. #if 0    
  200.     void        ReportJVMError(nsresult err);
  201.     const char* GetJavaErrorString(JNIEnv* env);
  202. #endif
  203.  
  204.     nsresult    AddToClassPath(const char* dirPath);
  205.     PRBool      MaybeStartupLiveConnect(void);
  206.     PRBool      MaybeShutdownLiveConnect(void);
  207.     PRBool      IsLiveConnectEnabled(void);
  208.     JSJavaVM*   GetJSJavaVM(void) { return fJSJavaVM; }
  209.  
  210.  
  211.     nsJVMManager(nsISupports* outer);
  212.     virtual ~nsJVMManager(void);
  213.  
  214. protected:    
  215.  
  216.     /**
  217.  
  218.      * @return conjure up THE nsIWebBrowserChrome instance from thin
  219.      * air!
  220.  
  221.      */
  222.  
  223.     nsresult    GetChrome(nsIWebBrowserChrome **theChrome);
  224.     const char* GetJavaErrorString(JRIEnv* env);
  225.  
  226.     nsIJVMPlugin*       fJVM;
  227.     nsJVMStatus         fStatus;
  228.     nsISupports*        fDebugManager;
  229.     JSJavaVM *          fJSJavaVM;  
  230.     nsVoidArray*        fClassPathAdditions;
  231.     char*               fClassPathAdditionsString;
  232.     PRBool              fStartupMessagePosted;
  233. };
  234.  
  235. /*******************************************************************************
  236.  * Symantec Debugger Stuff
  237.  ******************************************************************************/
  238.  
  239. class nsSymantecDebugManager : public nsISymantecDebugManager {
  240. public:
  241.  
  242.     NS_DECL_AGGREGATED
  243.  
  244.     NS_IMETHOD
  245.     SetDebugAgentPassword(PRInt32 pwd);
  246.  
  247.     static NS_METHOD
  248.     Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr,
  249.            nsJVMManager* nsJVMManager);
  250.  
  251. protected:
  252.     nsSymantecDebugManager(nsISupports* outer, nsJVMManager* nsJVMManager);
  253.     virtual ~nsSymantecDebugManager(void);
  254.  
  255.     nsJVMManager* fJVMMgr;
  256.  
  257. };
  258.  
  259. ////////////////////////////////////////////////////////////////////////////////
  260.  
  261. #endif // nsJVMManager_h___
  262.